Skip to content

Conversation

sideeffffect
Copy link
Contributor

No description provided.

Copy link
Contributor

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

@sideeffffect
Copy link
Contributor Author

I've noticed that compiling Rust takes a lot of time in CI. Hopefully this will help 🤞

@sideeffffect sideeffffect force-pushed the rust-cache branch 2 times, most recently from b0ac038 to 6e01f8c Compare October 8, 2025 00:38
@cgwalters
Copy link
Collaborator

Hi, thanks for submitting this! In general actually I'm trying to move most things into a container build, and there's some more nontrivial work to enable using this action with that.

We're relying today on intermediate cache layers in the container build. Now docker does have support for caching layers to/from GHA but podman doesn't directly. It might not be had to add though.

My inclination on compliation speedup here was to look at https://github.com/mozilla/sccache/

with:
cache-all-crates: true
save-if: ${{ github.ref == 'refs/heads/main' }}
lookup-only: ${{ github.ref == 'refs/heads/main' }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you setting lookup-only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will ensure that on main, no cache will be used and everything will be built from scratch.
But if you don't like it, it doesn't have to be there.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will ensure that on main, no cache will be used and everything will be built from scratch.

Yes, that's the effect the change has. I'm asking about why we want that effect - it's not the default, so you went to some effort to turn it on.

A github-wide search shows it's definitely used elsewhere but...why?

uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
save-if: ${{ github.ref == 'refs/heads/main' }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? My understanding is that due to how github handles caching we're safe against e.g. malicious PRs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will ensure that caches are saved only on main, not on any other PRs. I think that's enough caching. It may also have some vague security benefits.
But if you don't like it, it doesn't have to be there.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think anything that's not the default should have a comment with a rationale. When you say "enough caching" - is that to ensure that we're not evicting caches from git main with pull requests?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followup for this in bb0693c which adds comments, let me know if I got that wrong

@sideeffffect
Copy link
Contributor Author

Regarding why change the defaults: if the cache is always created in a pristine environment, there's much higher chance of working around any potential compiler bugs.

If the compiler and it's incremental compilation were 100% correct, we wouldn't need to worry about it.

But the potential for bugs is always there. This would give us most of the benefits of caching while avoiding potentially nasty problems related to caching.

But if you'd rather keep things simple, without these opt-in features, no worries, I'd be happy to remove it.


Regarding cashing via containers/layers/images, I don't have a good experience with it. You're in all likelihood much bigger expert then me. But I had trouble with determinism, the layers will have always different hashes, even for the same data; this is caused by timestamps which will continue to change. Thus the only reproducible container tool that I use now is JIB from Google (sbt-jib), it fixes the timestamps to 0 (or 2010-01-01 or something like that), ensuring the whole layer(s) have bit per bit identical data and thus hashes.

I hope this helps :)

@cgwalters cgwalters merged commit c17e631 into bootc-dev:main Oct 8, 2025
33 of 35 checks passed
@sideeffffect sideeffffect deleted the rust-cache branch October 8, 2025 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants